﻿using System.ComponentModel;
using System.Windows.Forms;

using Microsoft.WowAddonStudio.Project.Import;

namespace Microsoft.WowAddonStudio.Project.Import
{
	/// <summary>
	/// Base page of all pages that occur in add-in import wizard.
	/// </summary>
	public partial class ImportWizardPane : UserControl
	{
		public virtual object Settings { get; protected set; }

		#region Public events and event triggers

		/// <summary>
		/// Occurs when [set active].
		/// </summary>
		[Category("Wizard")]
		public event CancelEventHandler SetActive;

		/// <summary>
		/// Raises the <see cref="SetActive"/> event.
		/// </summary>
		/// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
		public virtual void OnSetActive(CancelEventArgs e)
		{
			if (SetActive != null)
				SetActive(this, e);
		}

		/// <summary>
		/// Occurs when [wizard next].
		/// </summary>
		[Category("Wizard")]
		public event WizardPageEventHandler WizardNext;

		/// <summary>
		/// Raises the <see cref="WizardNext"/> event.
		/// </summary>
		/// <param name="e">The <see cref="Microsoft.WowAddonStudio.Project.Import.WizardPageEventArgs"/> instance containing the event data.</param>
		public virtual void OnWizardNext(WizardPageEventArgs e)
		{
			if (WizardNext != null)
				WizardNext(this, e);
		}

		/// <summary>
		/// Occurs when [wizard back].
		/// </summary>
		[Category("Wizard")]
		public event WizardPageEventHandler WizardBack;

		/// <summary>
		/// Raises the <see cref="WizardBack"/> event.
		/// </summary>
		/// <param name="e">The <see cref="Microsoft.WowAddonStudio.Project.Import.WizardPageEventArgs"/> instance containing the event data.</param>
		public virtual void OnWizardBack(WizardPageEventArgs e)
		{
			if (WizardBack != null)
				WizardBack(this, e);
		}

		/// <summary>
		/// Occurs when [wizard finish].
		/// </summary>
		[Category("Wizard")]
		public event CancelEventHandler WizardFinish;

		/// <summary>
		/// Raises the <see cref="WizardFinish"/> event.
		/// </summary>
		/// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
		public virtual void OnWizardFinish(CancelEventArgs e)
		{
			if (WizardFinish != null)
				WizardFinish(this, e);
		}

		/// <summary>
		/// Occurs when [query cancel].
		/// </summary>
		[Category("Wizard")]
		public event CancelEventHandler QueryCancel;

		/// <summary>
		/// Raises the <see cref="QueryCancel"/> event.
		/// </summary>
		/// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
		public virtual void OnQueryCancel(CancelEventArgs e)
		{
			if (QueryCancel != null)
				QueryCancel(this, e);
		}

		#endregion

		#region Lifecycle methods

		/// <summary>
		/// Creates instances of <see cref="ImportWizardPane"/>.
		/// </summary>
		public ImportWizardPane()
		{
			InitializeComponent();
		}

		#endregion

		#region Protected member functions

		/// <summary>
		/// Gets the wizard.
		/// </summary>
		/// <returns></returns>
		protected ImportWizardForm GetWizard()
		{
			var wizard = (ImportWizardForm) ParentForm;
			return wizard;
		}

		/// <summary>
		/// Sets the wizard buttons.
		/// </summary>
		/// <param name="buttons">The buttons.</param>
		protected void SetWizardButtons(WizardButtons buttons)
		{
			GetWizard().SetWizardButtons(buttons);
		}

		/// <summary>
		/// Enables the cancel button.
		/// </summary>
		/// <param name="enableCancelButton">if set to <c>true</c> [enable cancel button].</param>
		protected void EnableCancelButton(bool enableCancelButton)
		{
			GetWizard().EnableCancelButton(enableCancelButton);
		}

		/// <summary>
		/// Presses the button.
		/// </summary>
		/// <param name="buttons">The buttons.</param>
		protected void PressButton(WizardButtons buttons)
		{
			GetWizard().PressButton(buttons);
		}

		#endregion
	}
}